#ifndef MQ_H_
#define MQ_H_
#include "conf.h"

/*
 * This message queue is a thread safe message queue
 * any operation for this queue is thread safe and fast.
 * The thread safe here means it allows one thread enqueue and
 * many other thread dequeue !
 * This queue is indeed a FIFO queue , the reason why I 
 * design this queue is specific in terms of our project
 * and also, using FIFO can make the queue very efficient
 * on lock policy and reduce even avoid lock contention!
 */
C_CODE_BEGIN
struct msgqueue;

EXPORT_FUNC struct msgqueue* msgqueue_create( size_t reserve_slots ,size_t objsize );
EXPORT_FUNC void  msgqueue_destroy( struct msgqueue* );
EXPORT_FUNC void  msgqueue_clear( struct msgqueue* );
EXPORT_FUNC void  msgqueue_enqueue( struct msgqueue* , void* );
EXPORT_FUNC void* msgqueue_head( struct msgqueue* );
EXPORT_FUNC void  msgqueue_dequeue( struct msgqueue* );

EXPORT_FUNC void*  msgqueue_xdequeue( struct msgqueue* , void* buf );

EXPORT_FUNC size_t msgqueue_size( struct msgqueue* );
EXPORT_FUNC bool msgqueue_empty( struct msgqueue* );


C_CODE_END


#endif // MQ_H_